package homeWorkk;

import java.math.BigDecimal;
import java.util.ArrayList;

public class work2 {
    public static void main(String[] args) {
        Student stu1 = new Student("张三","男",20,79.5);
        Student stu2 = new Student("李四","女",21,80.2);
        Student stu3 = new Student("王五","男",22,77.9);
        Student stu4 = new Student("周六","男",20,55.8);
        Student stu5 = new Student("赵七","女",21,99.9);
        ArrayList<Student> list = new ArrayList<>();
        BigDecimal bigDecimal = new BigDecimal(0);
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        list.add(stu4);
        list.add(stu5);
        for (int i = 0; i < list.size(); i++) {
           Student student =  list.get(i);
            bigDecimal = bigDecimal.add(BigDecimal.valueOf(student.getVal()));
            BigDecimal b=bigDecimal.divide(BigDecimal.valueOf(list.size()),2,BigDecimal.ROUND_HALF_UP);
            System.out.println(b);
        }

    }
}
